import { Layout } from "antd";
// import {CancelToken} from "axios"
import useSSE from "@/common/useSSE";
import MdViewer from "@/components/MdViewer";
import "./index.less";

const { Header, Sider, Content } = Layout;

const AskPage = () => {
  const { dialogueList, inputBox, answerBoxRef } = useSSE();

  // console.log(12, process.env, import.meta.env);

  // console.log(14, dialogueList)

  return (
    <Layout className="common-page test-page">
      <Header className="page-header">
        <div className="page-title">SSE测试</div>
      </Header>
      <Content className="page-content">
        <div className="w100 content-header" style={{ paddingTop: 16 }}>
          {/* <Button loading={loading} onClick={getData}>
            获取数据
          </Button> */}
          {inputBox}
        </div>
        <div className="content-box" style={{ overflow: "auto" }} ref={answerBoxRef}>
          {
            dialogueList.map((item, index) => {
              return (
                <div key={item.request_id} className="dialogue-item">
                  <div className="search-box">{item.text}</div>
                  <div className="result-box">
                    <MdViewer content={item.result}></MdViewer>
                  </div>
                </div>
              );
            })
          }
        </div>
      </Content>
    </Layout>
  );
};

export default AskPage;
